(function($) {
    $(function() {
        $("#mG_sidebar .tit a").click(function() {
            if ($(this.parentNode.parentNode).attr("class") == "menulist") {
                $(this.parentNode.parentNode).attr("class", "menulist menulistOff");
            } else {
                $(this.parentNode.parentNode).attr("class", "menulist");
            }
            var state = [];
            $("#mG_sidebar > div").each(function() {
                if ($(this).attr("class") == "menulist" || $(this).attr("class") == "menulist menulistOff")
                state.push($(this).attr("class") == "menulist menulistOff" ? 1 : 0);
            });
            document.cookie = "sidebar"+selecttab+"=" + parseInt(state.join(""), 2) + ";";
        });
    });

    $(function(){
        $("#frame_freshbtn").click(function(){
            var documentFrame = $("iframe")[0];
            documentFrame.contentWindow.location.reload(true);
        });
     });


     //多级联动
    $(function(){
        $(".selector").each(function() {
             $(this).selectorInit();
        });
    });
    //锚点
    $(function(){

        if(self!=top) { //在iframe 隐藏内页的返回顶部
            $(".A_gotop").hide();
        }
        $(".click_anchor").click(function() {
            var anchor_to = $(this).attr("href");
            if(anchor_to == '#iframe_parent_top') {
                $('html,body').animate({scrollTop: 0}, 500);
                return;
            }
            var anchor_top = $(anchor_to).offset().top;
            parent.window.goToHeight(anchor_top);
        });
    });

    //全选
    $(function(){
        $(".selectAll").click(function() {
            var link = $(this);
            var fstr = "input[name='"+link.attr("rel")+"']";
            if($(this).attr("checked")){
                $(document).find(fstr).attr("checked", true);
            }else{
                $(document).find(fstr).attr("checked", false);
            }
        });
    });
})(jQuery);


var COMPLAINT_OLD='';
function countComplaint(){
	var url = "/content/aj_complaint.php";
  	$.ajax({
	  	url: url,
        type: "GET",
        dataType: "html",   
        success: function(data){ 
    		if(data > 0 && $("#complaint_num")){
    			if(COMPLAINT_OLD == ''){
    				COMPLAINT_OLD = $("#complaint_num").find("a").html();
    			}
    		 	$("#complaint_num").find("a").html(COMPLAINT_OLD+"("+data+")");
    		}     
        }  
    });  
}
